package com.winning.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.channels.FileChannel;

public class IOUtils {

    public static <T> void close(T t) {
        try{
            if(t instanceof FileInputStream){
                ((FileInputStream) t).close();
            }else if(t instanceof OutputStream){
                ((OutputStream) t).close();
            }else if(t instanceof FileChannel){
                ((FileChannel) t).close();
            }else if(t instanceof Connection){
                ((Connection) t).close();
            }else if(t instanceof Channel){
                ((Channel) t).close();
            }
        }catch (Exception e){
            e.printStackTrace();
        }

    }

}
